Skip to content

ch32 USBHD/USBHS driver implementation#893

Draft
Copper280z wants to merge 88 commits into
ZigEmbeddedGroup:mainfrom
Copper280z:ch32_usb
Draft

ch32 USBHD/USBHS driver implementation#893
Copper280z wants to merge 88 commits into
ZigEmbeddedGroup:mainfrom
Copper280z:ch32_usb

Conversation

@Copper280z
Copy link
Copy Markdown
Contributor

@Copper280z Copper280z commented Jan 31, 2026

This adds a new driver for the ch32 USBHD/USBHS peripheral, USB_OTG_FS peripheral, and examples for the ch32v307, and ch32v203 boards.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 31, 2026

Lint Results

Found 12 issues on changed lines in 4 files:

  • examples/wch/ch32v/src/usb_cdc.zig: 1 issue
  • port/wch/ch32v/src/hals/clocks.zig: 1 issue
  • port/wch/ch32v/src/hals/usbfs.zig: 5 issues
  • port/wch/ch32v/src/hals/usbhs.zig: 5 issues

Comment thread examples/wch/ch32v/src/usb_cdc.zig
Comment thread port/wch/ch32v/src/hals/clocks.zig
Comment thread port/wch/ch32v/src/hals/usbfs.zig
Comment thread port/wch/ch32v/src/hals/usbfs.zig
Comment thread port/wch/ch32v/src/hals/usbfs.zig
Comment thread port/wch/ch32v/src/hals/usbhs.zig
Comment thread port/wch/ch32v/src/hals/usbhs.zig
Comment thread port/wch/ch32v/src/hals/usbhs.zig
Comment thread port/wch/ch32v/src/hals/usbhs.zig
_reserved1: u2 = 0,
});

fn baseAddr() usize {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change to base_addr, in MicroZig we use snake case for function names.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one actually makes sense

Copy link
Copy Markdown
Collaborator

@Grazfather Grazfather left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed everything except for the HALs themselves (since this is a draft). Will get to those when you think they're ready.

Comment thread core/src/core/usb.zig
Comment thread examples/wch/ch32v/build.zig
Comment thread examples/wch/ch32v/build.zig
Comment thread port/wch/ch32v/src/hals/ch32v20x.zig
Comment thread port/wch/ch32v/src/hals/ch32v30x.zig
Comment thread port/wch/ch32v/src/hals/clocks.zig
Comment thread examples/wch/ch32v/src/usb_cdc.zig
Comment thread examples/wch/ch32v/src/usb_cdc.zig
Comment thread examples/wch/ch32v/src/usb_cdc.zig
Comment on lines +114 to +116
// pins.tog.put(0);
usb_dev.poll(false, &usb_controller);
// pins.tog.put(1);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gets rid of toggle pins completely or uncomment these please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants